package cn.wolfcode.crm.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
@ToString
public class Customer {
    public static final int STATUS_ALL = -1;
    public static final int STATUS_POTENTIAL = 0;//潜在
    public static final int STATUS_FOMAL = 1;//正式
    public static final int STATUS_POOL = 2;//资源池
    public static final int STATUS_FAILURE = 3;//失败
    public static final int STATUS_LOST = 4;//流失

    public static final int GENDER_FEMALE = 0;//女
    public static final int GENDER_MALE = 1;//男

    private Long id;
    private String name;
    private Integer age;
    private Integer gender;
    private String tel;
    private String qq;
    private SystemDictionaryItem job;
    private SystemDictionaryItem source;
    private Employee seller;
    private Employee inputUser;
    private Date inputTime;
    private Integer status;
    public String getGenderName(){
        if(gender != null && GENDER_FEMALE == gender){
            return "女";
        } else if(gender != null && GENDER_MALE == gender){
            return "男";
        } else{
            return "未知";
        }
    }

    public String getStatusName(){
        if(status !=null &&status == STATUS_POTENTIAL){
            return "潜在客户";
        }else if(status !=null &&status == STATUS_FOMAL){
            return "正式客户";
        }else if(status !=null &&status == STATUS_POOL){
            return "资源池客户";
        }else if(status !=null &&status == STATUS_FAILURE){
            return "失败客户";
        }else if(status !=null &&status == STATUS_LOST){
            return "流失客户";
        }else{
            return "未知";
        }
    }
    public String getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("name",name);
        map.put("age",age);
        map.put("gender",gender);
        map.put("tel",tel);
        map.put("qq",qq);
        map.put("job",job);
        map.put("source",source);
        map.put("seller",seller);
        map.put("inputUser",inputUser);
        map.put("inputTime",inputTime);
        map.put("status",status);

        return JSON.toJSONString(map);
    }
}